//引入util js
var _util = require('util/util.js');

//account_service
var _market_service = {
    getallcoupons : function(pagesize,pageid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/coupon/coupons/query/pages/" +pagesize+"/"+pageid),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    getcouponsby : function(fullminus,shopname,pagesize,pageid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/coupon/"+fullminus+"/"+shopname+"/coupons/query/pages/"+pagesize+"/"+pageid),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    addcoupon : function(newcoupon,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/coupon/coupons"),
            data    : newcoupon,
            method  : 'POST',
            success : resolve,
            error   : reject,
        });
    },
    editcoupon : function(newcoupon,couponid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/coupon/"+couponid),
            data    : newcoupon,
            method  : 'PUT',
            success : resolve,
            error   : reject,
        });
    },
    deletecoupon : function(couponid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/coupon/"+couponid),
            method  : 'DELETE',
            success : resolve,
            error   : reject,
        })
    },
    getallswipers : function(pagesize,pageid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/swiperitem/swiperitems/query/pages/"+pagesize+"/"+pageid),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    getswipersbyname : function(selectname,pagesize,pageid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/swiperitem/"+selectname+"/swiperitems/query/pages/"+pagesize+"/"+pageid+"?slogan=<slogan>"),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    editswiper : function(newswiper,swiperid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/swiperitem/"+swiperid),
            data    : newswiper,
            method  : 'PUT',
            success : resolve,
            error   : reject,
        });
    },
    deleteswiper : function(swiperid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/swiperitem/"+swiperid),
            method  : 'DELETE',
            success : resolve,
            error   : reject,
        });
    },
    addswiper : function(newswiper,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/swiperitem/swiperitems"),
            data    : newswiper,
            method  : 'POST',
            success : resolve,
            error   : reject,
        });
    },
}

module.exports = _market_service;